package com.zj.inoutput.common.base;

import lombok.Getter;
import lombok.ToString;

import java.io.Serializable;

/**
 * @author DuanYu <a>Email:z-houjie@qq.com</a>
 * @date 2022-02-10 17:49
 */
@Getter
@ToString
public class BasePage implements Serializable {

    private static final long serialVersionUID = 0L;

    /**
     * 默认当前页
     */
    private static final int DEFAULT_INDEX = 1;

    /**
     * 默认每页条数
     */
    private static final int DEFAULT_SIZE = 10;

    /**
     * 最大每页条数
     */
    private static final int MXA_SIZE = 50;

    private Integer pageIndex;

    private Integer pageSize;

    public void setPageIndex(Integer pageIndex) {
        if (pageIndex == null || pageIndex <= 0) {
            this.pageIndex = DEFAULT_INDEX;
        } else {

            this.pageIndex = pageIndex;
        }
    }

    public void setPageSize(Integer pageSize) {
        if (pageSize == null || pageSize <= 0) {
            this.pageSize = DEFAULT_SIZE;
        } else {
            this.pageSize = pageSize > MXA_SIZE ? MXA_SIZE : pageSize;
        }
    }
}
